package com.bruce.pattern.behavioral.chain.demo2;

import com.bruce.pattern.behavioral.chain.Course;
import org.junit.Test;

/**
 * Created by bruce on 2018/11/11 18:16
 */
public class MainTest {

    @Test
    public void test1() {
        Course course = new Course();
        course.setArticle("责任链模式文章");
        course.setName("责任链模式");
        course.setVideo("责任链模式视频");

        Chain<Course> chain = new Chain<>();
        chain.nextHandler(new ChainHandler1())
                .nextHandler(new ChainHandler2())
                .nextHandler(new ChainHandler3());
        chain.execute(course);
    }

    @Test
    public void test2() {
        Course course = new Course();
        course.setArticle("责任链模式文章");
        course.setName("责任链模式");
        course.setVideo("责任链模式视频");

        ChainHandler<Course> chainHandler = new ChainHandler1();
        chainHandler
                .nextHandler(new ChainHandler2())
                .nextHandler(new ChainHandler3());

        chainHandler.execute(course);
    }


}
